package com.db.patterns.facade;

import java.math.BigDecimal;

/**
 * 银行外观类
 */
public class BankFacade {
    private AccountManagement accountManagement;
    private DepositManagement depositManagement;
    private LoanManagement loanManagement;

    public BankFacade() {
        accountManagement = new AccountManagement();
        depositManagement = new DepositManagement();
        loanManagement = new LoanManagement();
    }

    //提供给客户端的方法 - 开户并存款
    public void openAccountAndDeposit(String accountName, BigDecimal amount) {
        accountManagement.createAccount(accountName);
        depositManagement.deposit(accountName, amount);
        System.out.println("开户并存款操作完成。");
    }

    //提供给客户端的方法 - 取款并销户
    public void closeAccountAndDeposit(String accountName, BigDecimal amount) {
        depositManagement.withdraw(accountName, amount);
        accountManagement.closeAccount(accountName);
        System.out.println("取款并且销户");
    }

    //提供给客户端的方法 - 申请贷款并且批准
    public void applyAndApproveLoan(String accountName, BigDecimal amount) {
        loanManagement.applyForlLoan(accountName, amount);
        loanManagement.approveLoan(accountName);
        System.out.println("申请贷款并批准");
    }

}
